/**
 * Created by yunpeng on 2015/3/26.
 */
angular.module('starter.orderServices', [])
    .factory('OrderService',function($http){

        var rows = 10;
/*[{
 startstation:'郑州市 金水区'
 ,endstation:'北京市 涧西区'
 ,starttime:'2015-05-05'
 ,endtime:'2015-06-06'
 ,status:2
 ,price:5000
 ,contact:'李小姐'
 ,phone:'1234567891'
 ,note:'总共运3种型号10辆车'
 }]*/

        var total = [0,0];
        var idx = [0,0];
        var order = [[],[]];
        var page = [1,1];
        var param = [{
            rows:5
            ,page:1
            ,status:2
        }
        ,{
                rows:5
                ,page:1
                ,status:3
            }]
        var service = {
            switch:0
            ,noOrders:[false,false]
            ,busy:false
            ,putOrder:function(data ){
                total[service.switch] = data.total;
                order[service.switch] = data.rows;
            }
            ,appendOrder:function(data ){
                total[service.switch] = data.total;
                order[service.switch] = order[service.switch].concat(data.rows);
            }
            ,status:function(){
                return {
                    total:total[service.switch]
                    ,length:order[service.switch].length
                }
            }
            ,order:function(){
                return order[service.switch];
            }
            ,orders:function(){
                return order;
            }
            ,get: function() {
                var i = idx[service.switch];
                return order[service.switch][i];
            }
            ,set:function(o){
                var i = idx[service.switch];
                var obj = order[service.switch][i];
                obj.user = o.user;
                obj.carrier = o.carrier;
                obj.comment = o.comment;
            }
            ,param:function(){
                return param[service.switch];
            }
            ,setIdx:function(i){
                idx[service.switch] = i;
            }
            ,orderDetail:null
            ,comment:null
        }

        return service;
    })
    .factory('BidService' ,function($http){

    });